import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);


//store 仓库
export default new Vuex.Store({
	//state 状态
	state: {
		Id:1,
		dataList:[],
		sta:false,
		Qpath:'',
		navList:[],
		jifenList:[],
		sumtsta:false,
		dlsta:false
	},
	//行为,对状态进行改变,静态行为
	mutations:{
		getid(state,id){
			state.Id=id;
		},
		changeStatus(state){
			state.sta=!state.sta;
		},
		changeList(state,data){
			state.dataList = data;
		},
		changejifenList(state,data){
			state.jifenList = data;
		},
		showsubmitpage(state){
			state.sumtsta=!state.sumtsta;
		},
		showdlpage(state){
			state.dlsta=!state.dlsta;
		}	
	},
	//行为,异步行为
	actions:{
		requestNav(context,opt){
		if(opt.path=='news'){
			opt.a.$http({
					url:'/nav'
					
				}).then(function(res){
					context.state.navList=res.body;
					console.log(context.state);
				})
		}	
		if(opt.path=='read'){
			opt.a.$http({
					url:'/nav1'
					
				}).then(function(res){
					context.state.navList=res.body;
					console.log(context.state);
				})
		}
		if(opt.path=='person'){
			opt.a.$http({
					url:'/nav2'
					
				}).then(function(res){
					context.state.navList=res.body.ranking;
					console.log(context.state);
				})
			}
		}
	}
});
